//
//  THTreeHoleChildSendViewController.m
//  TreeHole
//
//  Created by apple on 2020/9/18.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "THTreeHoleChildSendViewController.h"

@interface THTreeHoleChildSendViewController ()

@end

@implementation THTreeHoleChildSendViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self stoneobs_ui_configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --configSubView
- (void)stoneobs_ui_configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(27, 137, UISCREEN_WIDTH - 54, 160)];
    header.backgroundColor = UIColor.whiteColor;
    header.layer.cornerRadius = 10;
    header.clipsToBounds = YES;
    [self.view addSubview:header];
    
    __weak typeof(self) weakSelf =  self;
    NSArray * array = @[@{@"title":@"发资讯",@"imageName":@"treehole_发资讯"},
                        @{@"title":@"写笔记",@"imageName":@"treehole_写笔记"},
                        @{@"title":@"拍视频",@"imageName":@"treehole_拍视频"}
    ];
    NSInteger count = array.count;
    CGFloat buttonWith = 75;
    CGFloat left = (header.width - array.count*buttonWith)/2;
    for (NSInteger i = 0 ;i < array.count;i ++) {
        NSDictionary * dic = array[i];
        NSString * imageName = dic[@"imageName"];
        NSString * title = dic[@"title"];
        STTools_MenuControl * menuControl = [[STTools_MenuControl alloc] initWithFrame:CGRectMake(0, 0, buttonWith, 100) imageName:imageName title:title titleColor:STONEOBS_UI_FIRST_TEXT_COLOR];
        [menuControl setOnSelctedControl:^(STTools_MenuControl *control) {
            [weakSelf stoneobs_action_on_selcted_title:title];
        }];
        menuControl.tag = 10000 + i;
        [header addSubview:menuControl];
        menuControl.left = left + i * buttonWith;
        menuControl.centerY = header.height/2;

    }
}
#pragma mark --stoneobs Action Method
- (void)stoneobs_action_on_selcted_title:(NSString*)title{
    if ([title isEqualToString:@"发资讯"]) {
        [self pushViewController:THAddTieZiViewController.new animated:1];
    }
    if ([title isEqualToString:@"拍视频"]) {
        [self pushViewController:THAddVideoViewController.new animated:1];
    }
    if ([title isEqualToString:@"写笔记"]) {
        THAddTieZiViewController * vc = THAddTieZiViewController.new;
        vc.is_add_note = YES;
        [self pushViewController:vc animated:1];
    }
}
@end
